#include<bits/stdc++.h>

using namespace std;
int n,m,l,v,d,w,aa,tt,t,ttf,s,ans;
double ss;
vector<pair<int,int>> a;
int tf[1000005],b[100005];
bool cmp(pair<int,int> x,pair<int,int>y)
{
    if(x.first==y.first) return x.second-x.first<y.second-y.first;
    else return x.first<y.first;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>tt;
    for(int ac=1;ac<=tt;ac++)
    {
        cin>>n>>m>>l>>v;
        a.clear();
        ans=0;
        memset(tf,0,sizeof(tf));
        memset(b,0,sizeof(b));
        a.push_back({0,0});
        for(int i=1;i<=n;i++)
        {
            cin>>d>>w>>aa;
            if(w>v && aa>=0)
            {
                a.push_back({d,l});continue;
            }
            if(!aa || (w<=v && aa<0)) continue;
            if(w==v)
            {
                if(aa>0) a.push_back({d+1,l});
                continue;
            }
            s=1e7;
            if(aa<0)
            {
                ss=-w*1.0/aa;
                s=floor(w*ss+0.5*ss*ss*aa);
            }
            ss=(v*v-w*w+1)/2.0/aa;
            if(w<v && d+ss>l) continue;

            if(w>v) a.push_back({d,min(l,int(d+floor(ss)))});
            else a.push_back({d+ceil(ss),min(l,s+d)});
        }
        for(int i=1;i<=m;i++)
        {
            cin>>t;tf[t]++;
        }
        for(int i=1;i<=l;i++)
        {
            tf[i]+=tf[i-1];
        }
        for(int i=1;i<a.size();i++)
        {
            if(tf[a[i].second]-tf[a[i].first-1]==0)
            {
                a.erase(a.begin()+i);
                i--;
            }
        }
        cout<<((int)a.size())-1<<" ";
        sort(a.begin(),a.end(),cmp);
        for(int i=1;i<a.size();i++) {b[i]=tf[a[i].second]-tf[a[i].first-1];}
        for(int i=1;i<=l;i++)
        {

            if(tf[i]>tf[i-1])
            {
                ttf=0;
                for(int j=1;j<a.size();j++)
                {
                    if(a[j].first<=i && a[j].second>=i && b[j]==1) ttf=1;
                }
                if(!ttf)
                {
                    ans++;
                    for(int j=1;j<a.size();j++) if(a[j].first<=i && a[j].second>=i) b[j]--;
                }
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}
